import type { ApiResponse } from '../index'
//这段代码是一个TypeScript模块，它定义了与天气相关的接口，并提供了一个函数来从API获取天气数据
interface WeatherCurrent {
  time: string
  temperature: number
  rain: number
  weather: string
}

interface WeatherForecast {
  date: string
  weather: string
  max_temp: number
  min_temp: number
  sunrise: string
  sunset: string
  uv_index: number
  precipitation: number
  wind_speed: number
}

interface WeatherData {
  location: string
  current: WeatherCurrent
  forecast: WeatherForecast[]
}
//并提供了一个函数来从API获取天气数据
export const weatherApi = {
  getWeather(address: string) {
    return fetch(`/weather-api/APIphp/weather/ExactlyweatherGetWord.php?address=${encodeURIComponent(address)}&code=1`)
        .then(res => res.json()) as Promise<ApiResponse<WeatherData>>
  }
} 